/*
* @Author: ZHELIHAO\fangshuqin
* @Date:   2018-05-15 18:11:30
* @Last Modified by:   ZHELIHAO\fangshuqin
* @Last Modified time: 2018-05-26 19:39:33
*/
{
     let EVENT_CLICK = Laya.Event.CLICK;
     
     class Property extends ui.Info.PropertyUI{
        constructor() {
             super();
             this.init();
        }

        init() {
            this.registerActions();
        }

        registerActions() {

            this.ACTIONS = {
                [GAME_CMDS.USERFIVEPROPERTY] : this.userPropertyInfo
            };
            Sail.io.register(this.ACTIONS, this);

        }

        userPropertyInfo(data, code, msg) {
            if(code !==0 ) return;
            let propertyList = data.list;
            //左边
            this.dom_reward.text   = propertyList[0].score ? propertyList[0].score : '-';
            this.dom_attack.text   = propertyList[1].score ? propertyList[1].score : '-';
            this.dom_snatch.text   = propertyList[2].score ? propertyList[2].score : '-';
            this.dom_football.text = propertyList[3].score ? propertyList[3].score : '-';
            this.dom_capture.text  = propertyList[4].score ? propertyList[4].score : '-';

            propertyList.forEach((item)=>{
                if(item.score<=0){
                    this.grade_tips.visible = true ;
                }else{
                    this.grade_tips.visible = false ;
                }
            })
            

            // 右边
            this.dom_num.text = data.num ? data.num : '-';
            this.dom_rate.text     = data.rate ? data.rate : '-';
            this.dom_avgScore.text   = data.avgScore ? data.avgScore + '分' : '-';

            if(!data.num || !data.rate || !data.avgScore){
                this.grade_tips.visible = true ;
            }

        } 

        exit () {
            Sail.io.unregister(this.ACTIONS);
        }
     }

     Sail.class(Property, "Com.Info.Property")
}